<template>
	<view class="content">

		<table>
			<tr>
				<td>会员标签搜索<input type="text" v-model="hui_yuan_bqi" style="background-color: bisque;"></td>
				<td style="display: flex;"><button type="submit" @click="ss()">搜索</button>
				<button type="submit" @click="add()">添加</button></td>
			</tr>
			<tr>
				<td>会员标签</td>
				<td>排序</td>
				<td>会员数量</td>
				<td>备注</td>
				<td>操作</td>
			</tr>

			<tr v-for="v in list">
				<td>{{v.HuiYuanBqi}}</td>
				<td>{{v.PaiXu}}</td>
				<td>{{v.HuiYuanNum}}</td>
				<td>{{v.BeiZhu}}</td>
				<td>
					<button @click="del(v.ID)">删除</button>
					
				</td>
			</tr>

		</table>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				hui_yuan_bqi: "",
			}
		},
		onShow() {
			this.get_data()
		},
		methods: {
			ss(){
				this.get_data()
			},
			add(){
				uni.navigateTo({
					url:"/pages/add/add"
				})
			},
			get_data() {
				uni.request({
					url: 'http://127.0.0.1:8080/list', //仅为示例，并非真实接口地址。
					data: {
						HuiYuanBqi: this.hui_yuan_bqi,
					},
					method: "GET",
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					success: (res) => {
						console.log(res.data)
						this.list = res.data.Data
					}
				});
			},
			del(id){
				uni.request({
					url: 'http://127.0.0.1:8080/del', //仅为示例，并非真实接口地址。
					data: {
						id:id
					},
					method: "POST",
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					success: (res) => {
						console.log(res.data)
					if (res.data.Cre==200) {
						alert("删除成功")
						this.get_data()
					}else{
						alert("删除失败")
					}
					
					
					}
				});
			},
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>